﻿@using eBusiness.App_DAL
@model IEnumerable<eBusiness.Models.Product>
<div style="display: table; text-align: center; background: #fff;">
    <div style="width: 100%; height: 40px; text-align: center; background: #ddd; text-transform: uppercase;
        font-weight: bold; color: blue; line-height: 40px;">
        <span>Hot Products</span>
    </div>
    @foreach (var item in Model)
    {
        <div class="hot_product_grid_item">
            <div>
                @*<a href="@Url.Action("Details", "Product", new { id = item.ID })">*@
                @{
                    var _unitOfWork = new UnitOfWork();
                    var cate = item.Categories.FirstOrDefault();
                    @*
                    foreach (var category in item.Categories)
                    {
                        <span>|@category.ID|@category.Name</span>
                    }*@

                    if (cate != null)
                    {
                        cate.Name = cate.Name.Replace(" ", "-");
                        var itemName = item.Name.Replace(" ", "-");

                        var href = Url.RouteUrl("ProductDetails", new { categoryId = cate.ID, categoryName = cate.Name, productId = item.ID, productName = itemName }, "http");
                        
                        <a href="@href">
                            <img width="150px" height="80px" src="@item.ThumbImage" alt="thumbImage" /></a>
                    }
                    else
                    {
                        // cate.Name = cate.Name.Replace(" ", "-");
                        var itemName = item.Name.Replace(" ", "-");
                        var href = "../../Product/Details/"+@item.ID+"/"+@itemName+".html";
                        <a href="@Url.Action("Details", "Product", new { productId = item.ID, productName = item.Name })">
                        @*<a href="@href">*@
                        @*<a href="@Url.Action("Details", "Product", new { id = item.ID, productName = item.Name })">*@
                            <img width="150px" height="80px" src="@item.ThumbImage" alt="thumbImage" /></a>
                    }
                    @*<img width="150px" height="80px" src="@item.ThumbImage" alt="thumbImage" /></a>*@
                }
            </div>
            <div class="hot_product_grid_item_name">
                <span><a href="@Url.Action("Details", "Product", new { id = item.ID })">@item.Name.GetLeft(20, false)</a></span>
            </div>
            <div class="hot_product_list_item_price">
                <span style="color: blue">@item.Price <span style="color: red">(@item.DiscountByPercent%)</span></span>
            </div>
        </div>
    }
    <div class="clearboth">
        <span></span>
    </div>
</div>
